import { BaseGame } from "./BaseGame";
import { Singleton } from "./common/Singleton";

export interface IUpdatable {
    update(dt: number): void;
}

export class GameManager extends Singleton {
    public game: BaseGame;
    public async initialize(): Promise<void> { };
    public destroy(): void { };
}


/**打开界面时需要的配置信息 */
export interface GameManagerConfig {
    /**初始化顺序，数值越大，越晚初始化，最小为0*/
    initOrder?: number
}

/**
 * 注册GameMannager，由Game对象统一管理
 * @param initOrder 初始化顺序，默认1，数值越大越晚初始化
 * @returns 
 */
export function regGameManager(config: GameManagerConfig = { initOrder: 1 }): ClassDecorator {
    //@ts-ignore
    if (!regGameManager.clzArr) {
        //@ts-ignore
        regGameManager.clzArr = []
    }
    return function (target) {
        //@ts-ignore
        regGameManager.clzArr.push(target);
        (target as any).config = config

    }
}

